<%@page import="com.situ.web.vo.PageInfo"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.situ.web.entity.Course"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.css"/>
<style type="text/css">
	.right{
		float: right;
		height: 40px;
		
	}
</style>
</head>
<body>
	<div style="width: 800px; height:200px; margin: 80px auto;">
		<a href="/Java202007Web/course_insert.jsp" class="btn btn-default btn-lg active right" role="button">添加</a>
		<form action="<%=request.getContextPath()%>/course?method=selectName" method="post">
			<input type="text" name="selectName" style="height: 36px;"/>
			<input type="submit" value="搜索"  style="height: 36px; width: 50px;">
		</form>
		<table class="table table-hover table-bordered">
		<tr  class="warning">
			<td style="width: 105px;">ID</td>
			<td>课程名称</td>
			<td>学分</td>
			<td>修改</td>
			<td>删除</td>
		</tr>
		<% 
			PageInfo pageInfo = (PageInfo)request.getAttribute("pageInfo");
			for	 (Course course : (ArrayList<Course>)pageInfo.getList()) {
		%>
			<tr>
				<td style="width: 105px;"><%=course.getId()%></td>
				<td><%=course.getName()%></td>
				<td><%=course.getCredit()%></td>
				<td><a href="/Java202007Web/course?method=selectId&id=<%=course.getId()%>&pageNo=<%=pageInfo.getPageNo()%>">修改</a></td>
				<td><a href="/Java202007Web/course?method=delete&id=<%=course.getId()%>&pageNo=<%=pageInfo.getPageNo()%>">删除</a></td>
			</tr>
		<%
			}
		%>
		</table>
	</div>
	<div style="width: 800px; margin: 0px auto;">
	<nav aria-label="Page navigation" align="center">
		<ul class="pagination">
   			<% 
   				if (pageInfo.getPageNo() == 1) {
   			%>	
   				<li class="disabled">
				<a href="#" aria-label="Previous">
					<span aria-hidden="true">&laquo;</span>
				</a>
				</li>
			<% 
   			} else {
   				%>
   				<li>
				<a href="/Java202007Web/course?method=selectPage&pageNo=<%=pageInfo.getPageNo() - 1%>" aria-label="Previous">
					<span aria-hidden="true">&laquo;</span>
				</a>
				</li>
   			
			<%
   			}
				for(int i = 1; i <= pageInfo.getTotalPage(); i++){
					if (i == pageInfo.getPageNo()) {
			%>			
						<li class="active"><a href="#"><%=i%></a></li>
			<%
					} else{
			%>		
					
						<li><a href="/Java202007Web/course?method=selectPage&pageNo=<%=i%>"><%=i%></a></li>
			<% 			
					}	
				} 
			if (pageInfo.getPageNo() == pageInfo.getTotalPage()){
			%>
				<li class="disabled">
					<a href="#" aria-label="Next">
					<span aria-hidden="true">&raquo;</span>
					</a>
				</li>
			<% 
			} else {
			%>
				<li>
					<a href="/Java202007Web/course?method=selectPage&pageNo=<%=pageInfo.getPageNo() + 1%>" aria-label="Next">
					<span aria-hidden="true">&raquo;</span>
					</a>
				</li>
			<%
			}
			%>	
		</ul>
	</nav>
	</div>
</body>
</html>